from typing import *


class Solution:
    def largestPerimeter(self, nums: List[int]) -> int:
        nums.sort()
        ans, tot = -1, 0
        for v in nums:
            if v < tot:
                ans = tot + v
            tot += v
        return ans
